
from tkinter import *

app = Tk()
app.title("模拟登录系统")
app.geometry("900x380")

pic = r'C:/Users/a/Desktop/test01.gif'

copy_label = Label(app, text = "XX科技 @ 广雅中学")
copy_label.pack(side = "bottom")


image_file = PhotoImage(file = pic)
canvas = Canvas(app)
canvas.create_image(0, 0, anchor = "nw", image = image_file)
canvas.place(x = 0, y = 0, width = 600, height = 360)

title_label = Label(app, text = "登录页面", font = ("楷体", 20))
title_label.place(x = 620, y = 160)


name_label = Label(app, text = "用户名")
name_label.place(x = 620, y = 220)
name_input = Entry(app, width = 20, textvariable = name_label)
name_input.place(x = 670, y = 220)

pwd_label = Label(app, text = "密码")
pwd_label.place(x = 620, y = 250)
pwd_input = Entry(app, width = 20, textvariable = pwd_label)
pwd_input.place(x = 670, y = 250)

def login_demo():
    msg = ""
    name = name_input.get()
    pwd = pwd_input.get()
    if (name == "") or (pwd == ""):
        msg = "信息不能为空"
        print(msg)
    elif (name != "admin") or (pwd != "111"):
        msg = "信息不正确"
        print(msg)
    elif (name == "admin") and (pwd == "111"):
        msg = "登录成功"
        print(msg)
    else:
        msg = ""
    msg = msg.center(14, "=")
    info_label = Label(app, text=msg)
    info_label.place(x=620, y=280)


login_button = Button(app, text = "登录", command = login_demo)
login_button.place(x = 620, y = 300 )

quit_button = Button(app, text = "退出", command = app.quit)
quit_button.place(x = 660, y = 300 )


app.mainloop()